

// JS错误日志，继承于日志基类MonitorBaseInfo
function UserBehavourInfo() {

    var needLogUp = true;
    var listenerClass = "trace_wrap";

    //在body上加class
    $(document.body).addClass(listenerClass);

    function getParam(e) {
        return {
            dt: new Date().getTime(),
            trace_id: e.target.getAttribute("_trace_id"),
            trace_remark: e.target.getAttribute("_trace_remark"),
            trace_trigger_type: e.type,
            value: e.target.value,
            client_x: parseInt(e.clientX),
            client_y: parseInt(e.clientY),
        };
    }
    function upLog(logMsg) {

        var data = {
            ...getCommonProperty(),
            uploadType: 'USER_BEHAVOUR',
            logMsg: logMsg
        }

        //nginx日志
        new Image().src = "http://log.besteasylearn.com/log.gif?appKey=123&json=" + JSON.stringify(data)

        $.post({
            url: "/log/up",
            data: data,
            async: false
        });
    }

    //点击监听
    $("." + listenerClass).on("click", "[_tarce_type*=click]", function (e) {
        if (!needLogUp) return false;
        upLog(getParam(e));
        return false;
    });

}

//用户行为
function recordUserBehavour() {

    $(function () {
        UserBehavourInfo();
    })


};

recordUserBehavour()
